
#ifndef __CLOCK_H_
#define __CLOCK_H_

#include "driver/gpio.h"
#include "driver/i2c.h"
#include "esp_err.h"
#include "esp_log.h"
#include "freertos/FreeRTOSConfig.h"

#include "iic.h"

#define PCF85063_SENSOR_ADDR            0x51
//06秒寄存器0x04      6秒寄存器地址是0x02 
#define PCF85063_SEC_REG_ADDR           0x02       /*!< Register addresses of the timer_second register */
//PCF85063_REG: sec=4,min=5,hour=6,day=7,week=8,month=9,year=10
 
typedef struct 
{
   int nYear;
   int nMonth;
   int nWeek;
   int nDay;
   int nHour;
   int nMin;
   int nSec;
} CTime;
 
uint8_t PCD85063TP_decToBcd(uint8_t val);
uint8_t PCD85063TP_bcdToDec(uint8_t val);
int PCF85063_get_Week(int y,int m,int d);
void PCF85063_setTime(CTime tm,int isAutoCalcWeek);
bool PCF85063_getTime(CTime *tm);
char *PCF85063_getTmString(int isYMD);
esp_err_t PCF85063_register_read(uint8_t reg_addr, uint8_t *data, size_t len);
esp_err_t PCF85063_register_write(uint8_t reg_addr, uint8_t *data,int len);

#endif
